package com.tanhua.model.vo;

import com.tanhua.model.db.SoulPaper;
import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.UserReport;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

//返回给前端的试卷对象
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReportVo implements Serializable {


    private String conclusion;                      //鉴定结果:狮子什么什么的
    private String cover;                           //封面
    private Dimensions[] dimensions;                //外向，判断，抽象，理性
    private List<ReportUserVo> similarYou;

    public static ReportVo init(UserReport userReport, List<UserInfo> userInfos,Long userId) {
        ReportVo vo = new ReportVo();
        vo.setConclusion(userReport.getConclusion());
        vo.setCover(userReport.getCover());
        //1.创建一个集合
         List<ReportUserVo> similarYou = new ArrayList<>();//空的
        //2.循环userInfos
        for (UserInfo userInfo : userInfos) {
            ReportUserVo reportUserVo = new ReportUserVo();
             if (userInfo.getId()!=userId){
                 Long id = userInfo.getId();
                 reportUserVo.setId(Integer.parseInt(id.toString()));//id设置完成
                 reportUserVo.setAvatar(userInfo.getAvatar());
             }

            similarYou.add(reportUserVo);
        }
        vo.setSimilarYou(similarYou);
        return  vo;
    }
}